﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogicUniversityBiz;

namespace LogicUniversity.Department_Head
{
    public partial class AssignDepRep : System.Web.UI.Page
    {
        CoreHeadFascade ef = new CoreHeadFascade();

        protected void Page_PreInit(Object sender, EventArgs e)
        {
            //if (Session["Role"] as string != "Employee" || Session["Role"] as string != "Representative")
            //{
            //    
            //}
            if (Session["Role"] as string != "Department Head")
            {
                if ((Session["TempRole"] as string) != "Department Head")
                {
                    Response.Redirect("~/Login.aspx");
                }
            }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CurrentTime.Text = DateTime.Now.ToString();

            
            //CurrentTime.Text = DateTime.Now.ToString();
            if (!IsPostBack)
            {
                ddlCollectionPoint.DataSource = ef.getcollectionpoint();
                ddlCollectionPoint.DataTextField = "Dept_Name";
                ddlCollectionPoint.DataValueField = "Dept_Name";
                ddlCollectionPoint.DataBind();

                string empID = Session["UserID"] as string;
                string deptCode = ef.getDepartmentCode(empID);
                ddlRepresentative.DataSource = ef.getRepresentativeName(deptCode);
                ddlRepresentative.DataTextField = "Employee_Name";
                ddlRepresentative.DataValueField = "Employee_Name";
                ddlRepresentative.DataBind();
            }
        }

        
        protected void ddlCollectionPoint_TextChanged(object sender, EventArgs e)
        {
          //  GridView1.DataSource=ef.getCollection(ddlCollectionPoint.SelectedValue.ToString());
        }

        
        protected void ddlCollectionPoint_SelectedIndexChanged(object sender, EventArgs e)
        {

            //GridView1.DataSource = ef.getCollection(ddlCollectionPoint.SelectedValue.ToString());
            //GridView1.DataBind();
        }

        protected void ddlRepresentative_SelectedIndexChanged(object sender, EventArgs e)
        {
            //GridView1.DataSource = ef.getRepCollection(ddlCollectionPoint.SelectedValue , ddlRepresentative.SelectedValue);
           // GridView1.DataSource = ef.getRepresentative(ddlRepresentative.SelectedValue.ToString());
           // GridView1.DataBind();
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {

            string DeptCode = ef.getDepartmentCode(Session["UserID"] as string);
            ef.getRepCollection(ddlCollectionPoint.SelectedValue, ddlRepresentative.SelectedValue,DeptCode);
           // GridView1.DataSource = ef.getRepresentative(ddlRepresentative.SelectedValue.ToString());
                      
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            //GridView1.DataSource = ef.getShowCollection(ddlCollectionPoint.SelectedValue, ddlRepresentative.SelectedValue);
            //GridView1.DataSource = ef.getRepresentative(ddlRepresentative.SelectedValue.ToString());
            //GridView1.DataBind();
            
        }

    }
}